package com.iecas.utils;

import cn.hutool.core.util.StrUtil;
import com.iecas.entity.User;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class OnlineManager {
    public static Map<String, User> onlineUser = new ConcurrentHashMap<>();

    public static User get(String token) {
        return onlineUser.get(token);
    }

    public static User set(String token, User user) {
        return onlineUser.put(token, user);
    }

    public static User remove(String token) {
        if (StrUtil.isNotBlank(token)){
            return onlineUser.remove(token);
        }
        return null;
    }
}
